package Animation;

import javax.media.opengl.GL;
public class Square
{
    int size;
    int topLeftX;
    int topLeftY;
    int zPosition;
    double[] color;
    String type;
    //if room = true then this square is a room. else it is a space.
    public Square(String type, int topLeftX, int topLeftY, int size)
    {
        this.topLeftX = topLeftX;
        this.topLeftY = topLeftY;
        color = new double[3];
        this.size = size;
        this.type = type;
        if (type.equals("space"))
        {
            color[0] = .61f;
            color[1] = .58f;
            color[2] = .34f;
            zPosition = 0;
        }

        else if (type.equals("room"))
        {
            
        }

        else if (type.equals("dice"))
        {
            color[0] = 1f;
            color[1] = 1f;
            color[2] = 1f;
            zPosition = 0;
        }
        
        else if (type.equals("board"))
        {
            color[0] = .36f;
            color[1] = .246f;
            color[2] = .150f;
            zPosition = 0;
        }
    }

    public void drawSquare(GL gl)
    {
        gl.glBegin(GL.GL_QUADS); // top right, top left, bottom left, bottom right
        gl.glColor3dv(color, zPosition);

        gl.glVertex3d(topLeftX + size, topLeftY,zPosition); // top right  
        gl.glVertex3d(topLeftX, topLeftY,zPosition); // top left
        gl.glVertex3d(topLeftX, topLeftY - size,zPosition); // bottom left
    
        if(type.equals("space"))
         gl.glColor3d(210, 180, 140);

        gl.glVertex3d(topLeftX + size, topLeftY - size, zPosition); //bottom right
        gl.glEnd();
    }

    public int getArea()
    {
        return ((topLeftX + size) * (topLeftY));
    }

    public int getSize() {
        return size;
    }

    public int getTopLeftX() {
        return topLeftX;
    }

    public int getTopLeftY() {
        return topLeftY;
    }

}